#ifndef __DBMANAGER_H__
#define __DBMANAGER_H__

#include "mydb.h"
#include "proto/message.pb.h"
#include <string>

class DBManager
{
public:
    ~DBManager();
    
    static std::shared_ptr<DBManager>& GetInstance();

    bool CreateUser(const std::string& userName, std::string& pwd);

    bool IsExistUserName(const std::string& username);

    bool IsMatch(const std::string& username, const std::string& password, int& playerId);

    void GetUserInfo(const std::string& username, proto::UserInfoResponse& userinfor);

    void GetRankList(std::vector<proto::RankListResponse>& rankList);

    int UpdateCoinCount(const std::string& username, int coincount);

    int GetCoin(const std::string& username);
private:
    DBManager();

private:
    static std::shared_ptr<DBManager> m_instance;
    MyDB::ptr mydb;
};

#endif // !__DBMANAGER_H__
